package com.example.flag03;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

public class MyDatabaseHelper extends SQLiteOpenHelper {
    public static final String CREATE_FLAG1="Create table Flag("
            +"_id integer primary key autoincrement,"
            +"flagTitle text,"
            +"flagPlan text,"
            +"timeList text,"
            +"signal text," //-1过期 0待完成 1已完成
            +"fromYear integer,"
            +"fromMonth integer,"
            +"fromDay integer,"
            +"toYear integer,"
            +"toMonth integer,"
            +"toDay integer,"
            +"finishedYear text,"
            +"finishedMonth text,"
            +"finishedDay text,"
            +"feel text)";

    public static final String CREATE_FLAG2="Create table Flag1("
            +"_id integer primary key autoincrement,"
            +"Year integer,"
            +"Month integer,"
            +"finish integer,"
            +"out integer,"
            +"report text,"
            +"give integer)";

    private Context mContext;
    public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
        super(context,name,factory,version);
        mContext =context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_FLAG1);
        db.execSQL(CREATE_FLAG2);
        Toast.makeText(mContext,"Create text succeeded",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists Book");
        onCreate(db);
    }
}
